﻿<%@ Page Title="" Language="C#" MasterPageFile="~/SkyFab.Master" AutoEventWireup="true" CodeBehind="MakeVendorPO.aspx.cs" Inherits="Web.MakeVendorPO" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:Label ID="FlashMessageLabel" runat="server"></asp:Label>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<h1>Create Vendor Purchase Order/Contract Order</h1>

    <div class="span-9">
    <fieldset>
    <legend>Vendor Information</legend>
    <p>
    <label>Vendor:</label>
    <asp:DropDownList ID="SupplierDropDownList" runat="server" AutoPostBack="True" 
                    onselectedindexchanged="SupplierDropDownList_SelectedIndexChanged" Width="200">
                </asp:DropDownList>
    </p>
    </fieldset>


    <fieldset>
    <legend>Shipping Address</legend>
    <p>
    <label>Ship-To:(Skyfab Address)</label>
    </p>
    <p>
     <asp:TextBox ID="ShipToTextBox1" runat="server" CssClass="text span-7"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                    ControlToValidate="ShipToTextBox1" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
    </p>

    <p>
    <asp:TextBox ID="ShipToTextBox2" runat="server" CssClass="text span-7"></asp:TextBox>
    </p>

    <p>
     <asp:TextBox ID="ShipToTextBox3" runat="server" CssClass="text span-7"></asp:TextBox>
    </p>
               
    <p>
    <label>Postal Code:</label>
    <asp:TextBox ID="ZipCodeTextBox" runat="server" CssClass="text" Width="150"></asp:TextBox>
    </p>
    </fieldset>
    </div>


    <div class="span-9">
    <fieldset>
    <legend>Order Information</legend>

     <p>
                <asp:RadioButtonList ID="POTypeRadioButtonList" runat="server" RepeatDirection="Horizontal">
                <asp:ListItem Text="Purchase Order" Value="purchase" Selected="True"/>
                <asp:ListItem Text="Contract Order" Value="contract" />
                </asp:RadioButtonList>
    </p>

    <p>
    <label>PO No.:</label>
    <asp:TextBox ID="PONumberTextBox" runat="server" CssClass="text" Width="180"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                    ControlToValidate="PONumberTextBox" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
    </p>

    <p>
    <label>Date:</label>
    <asp:TextBox ID="PODateTextBox" runat="server" CssClass="text" Width="150"></asp:TextBox>
                <asp:CalendarExtender ID="PODateTextBox_CalendarExtender" runat="server" 
                    Enabled="True" TargetControlID="PODateTextBox" Format="d MMM, yyyy">
                </asp:CalendarExtender>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                    ControlToValidate="PODateTextBox" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
    </p>

    <p>
    <label>Quotation No:</label>
    <asp:TextBox ID="ReferenceTextBox" runat="server" CssClass="text" Width="150"></asp:TextBox>
    </p>

    
    <p>
    <label>Total Qty:</label>
    <asp:TextBox ID="TotalQtyTextBox" runat="server" CssClass="text" Width="150"></asp:TextBox>
    </p>
    <p>(This field(Total Qty) is ONLY for contract order! Leave it blank for purchase order.)</p>


    <p>
    <label>Remark:</label>
    <asp:TextBox ID="RemarkTextBox" runat="server" Height="68px" TextMode="MultiLine" 
                    Width="229px"></asp:TextBox>
    </p>
    </fieldset>
    </div>

    <div class="span-18">
           <fieldset>
           <legend>Select Product</legend>
           <p>
           <label>Product No/ Revision:</label>
               <asp:DropDownList ID="ProductDropDownList" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ProductDropDownList_SelectedIndexChanged" Width="160">
               </asp:DropDownList>
                <asp:RequiredFieldValidator ID="ProductDropDownListRequiredFieldValidator" runat="server" 
                    ErrorMessage="*" ControlToValidate="ProductDropDownList" ForeColor="Red">
                    </asp:RequiredFieldValidator>
            
            <label>Requested Date:</label>
            <asp:TextBox ID="RequestDateTextBox" runat="server" CssClass="text" Width="150"></asp:TextBox>
                                <asp:CalendarExtender ID="RequestDateTextBox_CalendarExtender" 
                                    runat="server" TargetControlID="RequestDateTextBox"
                                    Format="d MMM, yyyy">
                                </asp:CalendarExtender>
                                <asp:RequiredFieldValidator ID="RequestDateTextBoxRequiredFieldValidator" runat="server" 
                                    ErrorMessage="*" ControlToValidate="RequestDateTextBox" ForeColor="Red">
                                </asp:RequiredFieldValidator>

            </p>

            <p>
            <label>Product Name:</label>
            <asp:Label ID="ProductNameLabel" runat="server"></asp:Label>
            </p>

            <p>
            <label>Quantity:</label>
            <asp:TextBox ID="QtyTextBox" runat="server" CssClass="text" Width="70"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="QtyTextBoxRequiredFieldValidator" runat="server" 
                                    ErrorMessage="*" ControlToValidate="QtyTextBox" ForeColor="Red">
                                </asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="QtyTextBoxRegularExpressionValidator" runat="server" 
                                ControlToValidate="QtyTextBox" ErrorMessage="*" ForeColor="Red" 
                                ValidationExpression="^[1-9]\d*$">
                                </asp:RegularExpressionValidator>

            <label>Net Price (SGD):</label>
            <asp:TextBox ID="PriceTextBox" runat="server" CssClass="text" Width="70"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="PriceTextBoxRequiredFieldValidator" runat="server" 
                                    ErrorMessage="*" ControlToValidate="PriceTextBox" ForeColor="Red">
                                </asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="PriceTextBoxRegularExpressionValidator" runat="server" 
                                ControlToValidate="PriceTextBox" ErrorMessage="*" ForeColor="Red" 
                                ValidationExpression="^[0-9]+(.[0-9]{1,2})?$">
                                </asp:RegularExpressionValidator>

            <label>Lot:</label>
            <asp:TextBox ID="LotTextBox" runat="server" CssClass="text" Width="70"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                    ErrorMessage="*" ControlToValidate="LotTextBox" ForeColor="Red">
                                </asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                                ControlToValidate="LotTextBox" ErrorMessage="*" ForeColor="Red" 
                                ValidationExpression="^[1-9]\d*$">
                                </asp:RegularExpressionValidator>
            
            <asp:Button ID="InsertButton" runat="server" onclick="InsertButton_Click" 
                                    Text="Insert" CssClass="submitButton" />
            </p>
           </fieldset>
        
     </div>

     <div class="span-18">
     <fieldset>
     <legend>Product List</legend>
     <p>
     <asp:CheckBox ID="ChooseSameDateCheckBox" runat="server" 
                oncheckedchanged="ChooseSameDateCheckBox_CheckedChanged" 
                AutoPostBack="True" />
            Choose same date for each item.
     </p>

     <p>
      <asp:GridView ID="VendorPOItemGridView" runat="server" 
                AutoGenerateColumns="False" CellPadding="4" 
                GridLines="None" CssClass="gridview" Width="100%">
                <AlternatingRowStyle BackColor="White" />
                <Columns>
                    <asp:BoundField DataField="ProductNo" HeaderText="No" />
                    <asp:BoundField DataField="ProductName" HeaderText="Name" />
                    <asp:BoundField DataField="Rev" HeaderText="Rev." />
                    <asp:TemplateField HeaderText="Requested Date">
                        <ItemTemplate>
                            <asp:TextBox ID="vRequestDateTextBox" runat="server" Text='<%#Eval("FormatDate") %>' Width="80px" ></asp:TextBox>
                            <asp:CalendarExtender ID="vRequestDateTextBox_CalendarExtender" runat="server" 
                                Enabled="True" TargetControlID="vRequestDateTextBox" Format="d MMM, yyyy">
                            </asp:CalendarExtender>
                            
                            <asp:RequiredFieldValidator ID="vRequiredFieldValidator1" runat="server" 
                                ControlToValidate="vRequestDateTextBox" ErrorMessage="*" ForeColor="Red">
                            </asp:RequiredFieldValidator>
                        </ItemTemplate>
                        
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Qty">
                        <ItemTemplate>
                            <asp:TextBox ID="vQtyTextBox" runat="server" Height="23px" Width="38px" Text='<%#Eval("RequestQty") %>' Enabled="false"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="vQtyTextBoxRequiredFieldValidator" runat="server" 
                                ControlToValidate="vQtyTextBox" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="vQtyTextBoxRegularExpressionValidator" runat="server" 
                                ControlToValidate="vQtyTextBox" ErrorMessage="*" ForeColor="Red" 
                                ValidationExpression="^[1-9]\d*$"></asp:RegularExpressionValidator>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Price(SGD)">
                        <ItemTemplate>
                            <asp:TextBox ID="vPriceTextBox" runat="server" Height="23px" Width="38px" Text='<%#Eval("Price") %>' Enabled="false"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="vPriceTextBoxRequiredFieldValidator" runat="server" 
                                ControlToValidate="vPriceTextBox" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="vPriceTextBoxRegularExpressionValidator" runat="server" 
                                ControlToValidate="vPriceTextBox" ErrorMessage="*" ForeColor="Red" 
                                ValidationExpression="^[0-9]+(.[0-9]{1,2})?$"></asp:RegularExpressionValidator>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Lot">
                        <ItemTemplate>
                            <asp:TextBox ID="LotTextBox" runat="server" Height="23px" Width="38px" Text='<%#Eval("Lot") %>'  ></asp:TextBox>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                                ControlToValidate="LotTextBox" ErrorMessage="*" ForeColor="Red" 
                                ValidationExpression="^[1-9]\d*$"></asp:RegularExpressionValidator>
                        </ItemTemplate>
                    </asp:TemplateField>
                    
                    <asp:TemplateField HeaderText="Delete">
                        <ItemTemplate>
                            <asp:Button ID="DeleteButton" runat="server" onclick="DeleteButton_Click" 
                                Text="Del" ToolTip="Delete" CssClass="submitButton" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    
                    <asp:TemplateField Visible="False">
                        <ItemTemplate>
                            <asp:HiddenField ID="ProductIdHiddenField" runat="server" Value='<%#Eval("ProductId") %>' Visible="False" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                
                    <AlternatingRowStyle BackColor="White" />
                    <EditRowStyle BackColor="#2461BF" />
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <PagerStyle HorizontalAlign="Center" CssClass="pagerTable" />
                    <RowStyle BackColor="#EFF3FB" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#F5F7FB" />
                    <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                    <SortedDescendingCellStyle BackColor="#E9EBEF" />
                    <SortedDescendingHeaderStyle BackColor="#4870BE" />
            </asp:GridView>
     
     </p>
     </fieldset>
     </div>


     <div class="span-9">
     <fieldset>
     <legend>Shipping Information</legend>
     <p>
     <label>Shipping Mode:</label>
     <asp:DropDownList ID="ShippingModeDropDownList" 
                runat="server" Width="150">
            <asp:ListItem>UPS</asp:ListItem>
            <asp:ListItem>FEDEX</asp:ListItem>
            </asp:DropDownList>
     </p>

     <p>
     <label>Carrier:</label>
     <asp:DropDownList ID="CarrierDropDownList" runat="server" Width="150">
                <asp:ListItem>UPS</asp:ListItem>
                <asp:ListItem>FEDEX</asp:ListItem>
            </asp:DropDownList>
     </p>

     <p>
     <label>Payment Terms:</label>
     <asp:DropDownList ID="PaymentTermsDropDownList" runat="server" Width="150">
                <asp:ListItem Value="WireTransfer">Wire Transfer</asp:ListItem>
                <asp:ListItem>Cash</asp:ListItem>
            </asp:DropDownList>
     </p>


     </fieldset>
     </div>


     <div class="span-9">
     <fieldset>
     <legend>PO Summary</legend>
     <p>
     <label>Total(SGD): </label>
     <asp:Label ID="TotalLabel" runat="server" Text=""></asp:Label>
     </p>

   

     <p>
         <asp:Button ID="SubmitButton" runat="server" Text="Submit" 
                onclick="SubmitButton_Click" CssClass="submitButton" />
&nbsp;
            <input type="reset" value="Reset" class="submitButton" />&nbsp;

            <asp:Button ID="PDFButton" runat="server" Text="Export PDF" 
                onclick="PDFButton_Click" CssClass="submitButton" />
     </p>
     </fieldset>
     </div>


</asp:Content>
